import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { poOrderPoListData } from '/@/api/m8/pu/order/poOrder';

const { t } = useI18n('sys.basVen');

const modalProps = {
  title: t('订单明细选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 90,
  showResetButton: false,
  schemas: [
    {
      label: t('扫一扫'),
      field: 'picBarCode',
      component: 'Input',
    },
    {
      label: t('供应商'),
      field: 'venCode',
      component: 'Input',
      show: false,
    },
    {
      label: t('图名'),
      field: 'picName',
      component: 'Input',
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('采购单号'),
    dataIndex: 'parent.code',
    key: 'a.code',
    sorter: true,
    width: 130,
    align: 'left',
    //slot: 'firstColumn',
  },
  {
    title: t('单据日期'),
    dataIndex: 'parent.ddate',
    key: 'a.ddate',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('销售单号'),
    dataIndex: 'm8Order.ccode',
    key: 'm8order.ccode',
    sorter: true,
    width: 150,
    align: 'left',
  },
  {
    title: t('图名'),
    dataIndex: 'picName',
    key: 'a.pic_name',
    sorter: true,
    width: 230,
    align: 'left',
  },
  {
    title: t('数量'),
    dataIndex: 'iqty',
    key: 'a.iqty',
    sorter: true,
    width: 80,
    align: 'right',
  },
  {
    title: t('累计入库数'),
    dataIndex: 'inQty',
    key: 'a.in_qty',
    sorter: true,
    width: 110,
    align: 'right',
  },
  {
    title: t('剩余入库数'),
    dataIndex: 'syRkQty',
    key: 'a.in_qty',
    sorter: true,
    width: 110,
    align: 'right',
  },
  {
    title: t('备注信息'),
    dataIndex: 'parent.remarks',
    key: 'a.remarks',
    sorter: true,
    width: 230,
    align: 'left',
  },
  {
    title: t('行备注'),
    dataIndex: 'remarks',
    key: 'a.remarks',
    sorter: true,
    width: 230,
    align: 'left',
  },
];

const tableProps: BasicTableProps = {
  api: poOrderPoListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'id',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'id',
  itemName: 'picName',
};
